package com.kimastrom.theGame.Model;

import android.graphics.PointF;

public class Ball {

	//The ball
	public final float mSize = 0.5f;
	public PointF mPosition = new PointF(3,3);
	public PointF mOldPosition = new PointF(3, 3);
	public PointF mVelocity = new PointF(0, 0);
	public final float ACCELLERATION =  0.3f;
	public final float MAX_SPEED =  1.0f;
	private final float pixelsPerMeter = 25.0f;
	
	public void restartBall() {
		mPosition = new PointF(3,3);
		mOldPosition = new PointF(3, 3);
		mVelocity = new PointF(0, 0);
	}
	
    public void updatePosition(float aAccX, float aAccY, float aTime) {
        // copy everything to local vars (hence the 'l' prefix)
        float lBallX, lBallY, lAx, lAy, lVx, lVy;
        
        lBallX = mPosition.x;
        lBallY = mPosition.y;
        lVx = mVelocity.x;            
        lVy = mVelocity.y;
        lAx = -aAccX;
        lAy = aAccY;

        lVx += (aTime * lAx) * pixelsPerMeter;
        lVy += (aTime * lAy) * pixelsPerMeter;

            mVelocity.x = lVx;
            mVelocity.y = lVy; 
            
    }
	
}
